/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.conexao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author egberto
 */
public class TesteConexao {
    
    private static final String STR_DRIVER = "org.gjt.mm.mysql.Driver";
    private static final String NOME_BANCO = "test";
    private static final String STR_CON = "jdbc:mysql://localhost:3306/"+NOME_BANCO;
    private static final String USER = "root";
    private static final String PASSWORD = "root";
    
    public static void main(String args[]){
        Connection conn = null;
        
        try{
            Class.forName(STR_DRIVER);
            conn = DriverManager.getConnection(STR_CON, USER, PASSWORD);
            System.out.println("Conectado");
            conn.close();            
        }catch(ClassNotFoundException e){
            System.out.println("Driver nao encontrado");
            e.printStackTrace();
        }catch(SQLException e){
            System.out.println("Erro ao obter a conexao");
            e.printStackTrace();
        }
    }
    
}
